package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.CondolencePayments;
import com.ruoyi.system.service.ICondolencePaymentsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 慰问金申请Controller
 * 
 * @author ruoyi
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/payments")
public class CondolencePaymentsController extends BaseController
{
    @Autowired
    private ICondolencePaymentsService condolencePaymentsService;

    /**
     * 查询慰问金申请列表
     */
    @RequiresPermissions("system:payments:list")
    @GetMapping("/list")
    public TableDataInfo list(CondolencePayments condolencePayments)
    {
        startPage();
        List<CondolencePayments> list = condolencePaymentsService.selectCondolencePaymentsList(condolencePayments);
        return getDataTable(list);
    }

    /**
     * 导出慰问金申请列表
     */
    @RequiresPermissions("system:payments:export")
    @Log(title = "慰问金申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CondolencePayments condolencePayments)
    {
        List<CondolencePayments> list = condolencePaymentsService.selectCondolencePaymentsList(condolencePayments);
        ExcelUtil<CondolencePayments> util = new ExcelUtil<CondolencePayments>(CondolencePayments.class);
        util.exportExcel(response, list, "慰问金申请数据");
    }

    /**
     * 获取慰问金申请详细信息
     */
    @RequiresPermissions("system:payments:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(condolencePaymentsService.selectCondolencePaymentsById(id));
    }

    /**
     * 新增慰问金申请
     */
    @RequiresPermissions("system:payments:add")
    @Log(title = "慰问金申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CondolencePayments condolencePayments)
    {
        return toAjax(condolencePaymentsService.insertCondolencePayments(condolencePayments));
    }

    /**
     * 修改慰问金申请
     */
    @RequiresPermissions("system:payments:edit")
    @Log(title = "慰问金申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CondolencePayments condolencePayments)
    {
        return toAjax(condolencePaymentsService.updateCondolencePayments(condolencePayments));
    }

    /**
     * 删除慰问金申请
     */
    @RequiresPermissions("system:payments:remove")
    @Log(title = "慰问金申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(condolencePaymentsService.deleteCondolencePaymentsByIds(ids));
    }
}
